﻿@model pdtransport_v2._0.Models.TenXe
@{
    ViewBag.Title = "Sua";
    Layout = "~/Areas/back/Views/Shared/_back_layout.cshtml";
}
@section scripts
{
    <script type="text/javascript">
        function onclick_CheckAll() {
            var list = document.getElementsByName("check[]");
            var v = document.getElementById("idCheclAll").checked;
            for (var i = 0; i < list.length; i++) {
                list[i].checked = v;
                updateList();
            }
        }

        function updateList() {
            var list = document.getElementsByName("check[]");
            //alert(list.length);
            var i;
            var s = "";
            for (i = 0; i < list.length; i++) {
                if (list[i].checked)
                    s = s + list[i].value + ",";
            }
            document.getElementById("txtCheckList").value = s;
        }
        function LoadImages(href) {
            searchPic = new Image();
            searchPic.src = href; // This is correct and the path is correct
            searchPic.onload = function () {
                document["pic1"].src = searchPic.src;
            }
        }
        $(document).ready(function () {
            $('#hinhbtn').click(function () {
                LoadImages($('#hinhdaidien').val());
            });
        });
        function ThongTinChiTiet() {
            // alert("abc");
            if (document.getElementById("khungchitiet").style.display == "none") {
                document.getElementById("khungchitiet").style.display = "inline";
                return;
            }
            else {
                document.getElementById("khungchitiet").style.display = "none";
                return;
            }
        }
    </script>
}
<h2>Sửa thông tin tên xe</h2>

<div class="block">
@if (ViewBag.Sua == 1)
{
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">
            ×</button>
        <h4>
            Thành Công!</h4>
        Chỉnh sửa thông tin thành công.
    </div>
}
    <form method="post" enctype="multipart/form-data">
    <table class="form">
        <tbody>
        <input type="hidden" name="idtx" value="@Model.IDTenXe" />
            <tr>
                <td class="col1">
                    <label>
                        Tên Xe</label>
                </td>
                <td class="col2">
                    <input type="text" name="tenxe" value="@Model.TenXe1/>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Hãng</label>
                </td>
                <td>
                    <select name="hang">
                @foreach (var item in ViewBag.hang)
                {
                    <option value="@item.IDHang" @if (item.IDHang == ViewBag.hang.IDHang) { ViewContext.Writer.Write("selected"); }>@item.TenHang</option>
                }
                </select>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Loại Xe</label>
                </td>
                <td>
                    <select name="loaixe">
                @foreach (var item in ViewBag.loaixe)
                {
                    <option value="@item.IDLX" @if (item.IDLX == ViewBag.loaixe.IDLX) { ViewContext.Writer.Write("selected"); }>@item.LoaiXe1</option>
                }
                </select>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Loại Hình Dịch Vụ</label>
                </td>
                <td>
                    <select name="loaihinh">
                @foreach (var item in ViewBag.loaihinh)
                {
                    <option value="@item.IDLHDV" @if (item.IDLHDV == ViewBag.loaihinh.IDLHDV) { ViewContext.Writer.Write("selected"); }>@item.TenLHDV</option>
                }
                </select>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                       Tình trạng</label>
                </td>
                <td>
                    <select name="tinhtrang">
                    <option value= 1 @if (ViewBag.xe._xe.TinhTrang == 1) { ViewContext.Writer.Write("selected"); }>
                        Enabled</option>
                    <option value= 0 @if (ViewBag.xe._xe.TinhTrang == 0) { ViewContext.Writer.Write("selected"); }>
                        Disabled</option>
                    </select>
                </td>
            </tr>
            <tr>
            <td class="col1">
            <label>Hình Ảnh
            </label>
                </td>
                <td class="col2">
                    <div id="myCarousel" class="carousel slide">
    <!-- Carousel items -->
    <div class="carousel-inner">
        <div class="active item">
            <ul class="thumbnails">
                @{
					int flag=0;
					foreach (var s in ViewBag.hinh)
					{
						flag=1;
						<li class="span2">
						<div class="thumbnail">
							<img width="222" height="163" src="/Content/images/@s.Hinh1" alt="" style="width: 222px; height:85px;"/>
							<label class="checkbox">
								<input type="checkbox" value = "@s.ID" name="check[]" onclick='return updateList();'/>
                                <p style="padding-top: 8px; margin-bottom: 0px; color: Blue; font-style: oblique;">Chọn để xóa</p>
							</label>
						</div>
						</li>
					}
                }
            </ul>
             <label class="checkbox">
                @if (flag==1)
                {
                    <input type='checkbox' id='idCheclAll' value='Button' onclick='return onclick_CheckAll();'/>
                    <p style="padding-top: 10px; margin-bottom: 0px; color: Blue; font-style: oblique;"><strong>Chọn tất cả</strong></p>
                }
            </label>
            <input type="hidden" id="txtCheckList" name="txtCheckList" value=""/>  
            </div>
            </div>
</div>
                </td>
            </tr>
            <tr>
                <td class="col1">
                <label>Upload hình ảnh</label>
                </td>
                <td class="col2">
                      <label for="file1">Filename:</label>
                      <input type="file" name="files" id="file1" />
                      <br />
                      <label for="file2">Filename:</label>
                      <input type="file" name="files" id="file2" />
                      <br />
                      <label for="file3">Filename:</label>
                      <input type="file" name="files" id="file3" />
                      <br />
                </td>
            </tr>
            <tr>
            <input type="hidden" id="txtCheckList" name="txtCheckList" value=""/>  
            </tr>
            <tr>
                <td class="col1">
                </td>
                <td class="col2">
                    <button type="submit" class="btn btn-small btn-blue">Sửa</button>
                    @Html.ActionLink("Thoát", "Danhsach", "Nhanvien", new{@class="btn btn-small"})
                </td>
            </tr>
        </tbody>
    </table>
    </form>
</div>


